<xsl:stylesheet version="1.1"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:our="http://www.ouroboroswiki.com/ext">

  <xsl:output method="xml" indent="yes" />
  <xsl:param name="input-mime-type">text/plain</xsl:param>
  <xsl:param name="input-path"/>
  <xsl:param name="input-repo"/>
  <xsl:param name="input-editable">false</xsl:param>

  <xsl:template match="/">
    <div>
       <table>
         <tr>
         	<th>Parent Key</th>
         	<th>Path</th>
         	<th>Repo</th>
         	<th>View</th>
         	<th>Edit</th>
         	<th>Validation</th>
         </tr>
		 <xsl:apply-templates select="content/original/meta"/>
       </table>
	   <xsl:comment><xsl:value-of select="content/escaped"/></xsl:comment>
    </div>
  </xsl:template>
  
  <xsl:template match="meta">
  	<xsl:param name="indent">0</xsl:param>
  	<tr>
  		<td><span style="padding-left: {$indent * 20}px;"><xsl:value-of select="@key"/></span></td>
  		<td><span><xsl:value-of select="@path"/></span></td>
  		<td><xsl:value-of select="@repo"/></td>
  		<td>
  			<xsl:if test="@repo">
 				<our:link repo="{@repo}.view" path="{@path}">view</our:link>
 			</xsl:if>
  		</td>
  		<td>
  			<xsl:if test="@writable = 'true' and @repo">
  				<our:link repo="{@repo}.edit" path="{@path}">edit</our:link>
  			</xsl:if>
  		</td>
  		<td>
  			<xsl:if test="count(validation)>0">
  				<ul>
		  			<xsl:foreach select="validation">
		  				<li><xsl:value-of select="@message"/></li>
		  			</xsl:foreach>
	  			</ul>
	  		</xsl:if>
  		</td>
  	</tr>
	<xsl:apply-templates select="meta">
		<xsl:with-param name="indent" select="$indent + 1"/>
	</xsl:apply-templates>
  </xsl:template>
  
</xsl:stylesheet>